import 'package:backend.core/core/domain/entities/admin.dart';
import 'package:backend.core/core/domain/entities/user_role.dart';
import 'package:backend.core/core/infrastructure/dtos/api/api_user_dto.dart';
import 'package:backend.core/core/infrastructure/dtos/api/api_user_role_dto.dart';
import 'package:equatable/equatable.dart';

class ApiAdminDto extends Equatable implements ApiUserDto {
  const ApiAdminDto._internal({
    required this.id,
    required this.email,
  });

  @override
  final String id;

  @override
  final String email;

  @override
  UserRole get role => UserRole.admin;

  @override
  List<Object?> get props {
    return [
      id,
      email,
    ];
  }

  factory ApiAdminDto.fromEntity(Admin admin) {
    return ApiAdminDto._internal(
      id: admin.id,
      email: admin.email,
    );
  }

  @override
  Map<String, dynamic> toJson() {
    final roleDto = ApiUserRoleDto.fromEntity(role);
    final roleString = roleDto.toString();

    return {
      kApiUserIdKey: id,
      kApiUserEmailKey: email,
      kApiUserRoleKey: roleString,
    };
  }
}
